<template>
	<ly-tree 
		:tree-data="treeData"
		:ready="ready"
		node-key="id" 
		@node-click="handleNodeClick"
	/>
</template>

<script>
	import LyTree from '@/components/ly-tree/ly-tree.vue'
	
	export default {
		components: {
			LyTree
		},
		props: {
			data: {
				type: Array,
				default() {
					return []
				}
			}
		},
		data() {
			return {
				ready: false,
				treeData: []
			}
		},
		created() {
			this.$nextTick(()=>{
				this.treeData = this.data
				this.ready = true;
			})
		},
		methods: {
			handleNodeClick(data) {
				this.$emit("clickTreeNode", data)
			}
		}
	};
</script>
